package com.swingson.componentprocessor;

import com.swingson.SwingsonGui;
import com.swingson.jsonparser.JsonObject;
import java.awt.Component;
import java.awt.Container;
import javax.swing.JComponent;

/**
 * @author sad
 */
public abstract class BaseProcessor {

    public abstract JComponent createComponent(JsonObject jsonElement, JComponent parent, SwingsonGui gui);

    public void processComponent(JsonObject jsonElement, JComponent currentComponent, JComponent parent, SwingsonGui gui) {
        JsonPropertiesProcessor processor = new JsonPropertiesProcessor();
        processor.processProperties(jsonElement, currentComponent, gui, parent);
    }

    public abstract Class[] getProcessingClass();

    @Override
    public String toString() {
        return "ComponentProcessor " + this.getClass().getSimpleName();
    }

    public void addCompomentToThis(Container parent, Component child, Object layoutParameter) {
        if (layoutParameter != null) {
            parent.add(child, layoutParameter);
        } else {
            parent.add(child);
        }
    }

    public CustomAddToParentStrategy getCustomAddToParentStategy() {
        return null;
    }

    public abstract class CustomAddToParentStrategy {

        public abstract void addCompomentToParent(Container parent, Component child, Object layoutParameter);
    }
}
